<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <style>
            #div1{width: 200px; height: 100px; background-color: red; border: 1px solid black}
        </style>
        <script>
            window.onload = function(){
                var oDiv = document.getElementById("div1");
                setInterval(function(){
                    // alert(oDiv.offsetWidth); //width + border
                    oDiv.style.width = oDiv.offsetWidth - 1 + 'px';
                }, 30);
            }
        </script>
    </head>
    <body>
        <div id = 'div1'></div>
    </body>
</html>